package com.shoping.web.component.processor;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * TODO
 *
 * @author zengweilong
 * @date 4/21/21 9:50 PM
 */
@Slf4j
@Component
public class MyBeanPostProcess implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (StringUtils.equals(beanName, "teacherService")) {
            System.out.println("BeanPostProcessor 执行了 BeanBefore = " + bean);
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (StringUtils.equals(beanName, "teacherService")) {
            System.out.println("BeanPostProcessor 执行了 After = " + bean);
        }
        return bean;
    }
}
